package com.demo.flight.controller;

import com.demo.flight.config.Result;
import com.demo.flight.config.ResultCodeEnum;
import com.demo.flight.entity.Seat;
import com.demo.flight.service.SeatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author ssy
 * @create 2022-03-25 12:57
 */

@CrossOrigin
@ResponseBody
@Controller
@RequestMapping("/seat")
public class SeatController {
    @Autowired
    private SeatService seatService;
    
    @GetMapping("/get/allAvailable")
    public Result getAllAvailable(Integer flightId) {
        if (flightId == null) {
            return Result.error(ResultCodeEnum.PARAM_ERROR);
        }
        List<Seat> seatList = seatService.getAllAvailable(flightId);
        return Result.success(seatList, ResultCodeEnum.SUCCESS);
    }
}
